<template>
	<view style="width: 100vw; min-height: 100vh;background-color: #F8F8F8;">
		<!-- 轮播图 -->
		<view class="">
			<fui-swiper-dot :items="items" :current="current">
				<swiper class="fui-banner__wrap" @change="change" circular :indicator-dots="false" autoplay
					:interval="4000" :duration="150">
					<swiper-item v-for="(item,index) in items" :key="index">
						<view class="fui-banner__item" :style="{background:item.background}">商品图片</view>
					</swiper-item>
				</swiper>
			</fui-swiper-dot>
		</view>
		<!-- 商品信息 -->
		<view class="" style="padding: 20rpx;">
			<!-- 标题 -->
			<view class="box">
				我是商品的标题
			</view>
			<!-- 商品规格 -->
			<view class="box flex" style="flex-wrap: wrap;">
				<view class="guigeBox" v-for="(item,index) in guigeList" :key="index">
					{{item.name}}
				</view>
			</view>
			<view class="box">
				商品详情介绍
				商品详情介绍
				商品详情介绍
				商品详情介绍
				商品详情介绍
				商品详情介绍
				商品详情介绍
				商品详情介绍
				商品详情介绍
				商品详情介绍
			</view>
		</view>
		<view class="bottomBox flex" :style="{'bottom':bottomHight+'rpx'}" v-if="type=='examine'">
			<view class="contact">
				<fui-button height="70rpx" style="width: 100%;" text="联系卖家" type="primary"></fui-button>
			</view>
			<view class="buy">
				<fui-button height="70rpx" @click="toBuy" style="width: 100%;" text="立即购买" type="success"></fui-button>
			</view>
		</view>
		<view class="bottomBox flex" :style="{'bottom':bottomHight+'rpx'}" v-if="type=='edit'">
			<view class="contact">
				<fui-button height="70rpx" style="width: 100%;" text="删除商品" type="primary"></fui-button>
			</view>
			<view class="buy">
				<fui-button height="70rpx" @click="toEdit" style="width: 100%;" text="编辑商品" type="success"></fui-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 'examine',
				bottomHight: 0,
				current: 0,
				guigeList: [{
					name: '第一规格',
					oldPrice: '100',
					newPrice: '80',
					limited: 10,
					bought: 1,
				}, {
					name: '第二规格',
					oldPrice: '100',
					newPrice: '80',
					limited: 10,
					bought: 1,
				}],
				items: [{
					background: '#09BE4F'
				}, {
					background: '#FFB703'
				}, {
					background: '#B2B2B2'
				}]
			}
		},
		onLoad(option) {
			this.type = option.type
			console.log(option, '编辑');
		},
		mounted() {
			let app = uni.getSystemInfoSync()
			this.bottomHight = app.safeAreaInsets.bottom
			console.log('app', app);
		},
		methods: {
			toEdit() {
				uni.navigateTo({
					url: '/publicPages/goods/form'
				})
			},
			toBuy() {
				uni.navigateTo({
					url: '/publicPages/goods/goumai'
				})
			},
			change(e) {
				this.current = e.detail.current;
			}
		}
	}
</script>

<style lang="scss">
	view {
		box-sizing: border-box;
	}

	.box {
		background-color: white;
		border-radius: 20rpx;
		padding: 20rpx;
		margin-bottom: 20rpx;
	}

	.fui-banner__item {
		width: 100%;
		height: 400rpx;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 34rpx;
		font-weight: 600;
	}

	.guigeBox {
		font-size: 28rpx;
		padding: 10rpx 20rpx;
		background-color: #F8F8F8;
		border-radius: 20rpx;
		margin-right: 10rpx;
		margin-bottom: 10rpx;
	}

	.fui-banner__wrap {
		height: 400rpx;
	}

	.bottomBox {
		border-top: 1rpx solid #ebebeb;
		position: fixed;
		bottom: 0rpx;
		width: 100vw;
	}

	.contact {
		padding: 20rpx;
		text-align: center;
		width: 30%;
	}

	.buy {

		padding: 20rpx;

		text-align: center;
		width: 70%;

	}
</style>